package day20180129.designMode.five_Singleton;

/**
 * Created by 14394 on 2018/1/29.
 */
//适用于多线程
public class Singleton1 {

    private static Singleton1 singleton1 = null;

    private Singleton1(){
        System.out.println("生成了一个实例。");
        slowdown();
    }

    private void slowdown() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static synchronized Singleton1 getInstance(){
        if (singleton1==null){
            singleton1 = new Singleton1();
        }
        return singleton1;
    }
}
